from random import random

money = 500
determine = 1
while determine == 1 and determine != 2:
    n = int(random() * 100)
    print(n)
    guess = int(input("请输入你的答案"))
    if guess > n:
        print("猜大了")
        money -= 500
    elif guess < n:
        print("猜小了")
        money -= 500
    else:
        print("恭喜猜中，本轮幸运数字:", n)
        money += 3000

    print("您的余额为:", money)
    print("是否继续游戏？")
    while 1:
        determine = int(input(" 1.继续  2.退出"))
        if determine == 1 and money < 500:
            print("不好意思，余额不足")
            determine=2
            break
        if determine == 1:
            print("新的游戏开始了！")
            break
        elif determine == 2:
            determine = 2
            print("退出成功")
            break
        else:
            print("非法输入请重试!")
